package com.pluto.cloud.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.context.request.async.DeferredResult;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
@EnableDiscoveryClient
@EnableSwagger2
public class SpringCloudServiceProviderA01Application {

	public static void main(String[] args) {
		SpringApplication.run(SpringCloudServiceProviderA01Application.class, args);
	}


	@Bean
	public Docket demoApi() {
		return new Docket(DocumentationType.SWAGGER_2)
				.groupName("captcha")
				.genericModelSubstitutes(DeferredResult.class)
				//  .genericModelSubstitutes(ResponseEntity.class)
				.useDefaultResponseMessages(false)
				.forCodeGeneration(false)
				.pathMapping("/")
				.select()
				.paths(PathSelectors.regex("/api/.*"))//过滤的接口
				.build()
				.apiInfo(captchaApiInfo());
	}


	private ApiInfo captchaApiInfo() {
		Contact contact = new Contact("王宏庭", "http://www.welinkdata.com", "hongting.wang@welinkdata.com");
		ApiInfo apiInfo = new ApiInfo("API",//大标题
				"REST API",//小标题
				"0.1",//版本
				"www.welinkdata.com",
				contact,//作者
				"主页",//链接显示文字
				""//网站链接
		);
		return apiInfo;
	}
}
